package com.dongdongshop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.enums.ResultEnums;
import com.dongdongshop.pojo.TbOrder;
import com.dongdongshop.service.TbOrderItemService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("TbOrderItem")
public class TbOrderItemController {

    //注入service
    @DubboReference
    private TbOrderItemService tbOrderItemService;

    //获取代发货数据
    @ResponseBody
    @RequestMapping("showOrder")
    public Result showOrder() {
        try {
            List<TbOrder> list = tbOrderItemService.showOrder();
            for (int i = 0; i < list.size(); i++) {
                list.get(i).setOrderIds(Long.toString(list.get(i).getOrderId()));
            }
            return Result.response(ResultEnums.SHOW_SUCCESS).setData(list);
        } catch (Exception e) {
            return Result.response(ResultEnums.SHOW_ERROR);
        }
    }
}
